<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@include file="../AllLoad.jsp" %>
<script type="text/javascript">
	function update_role(){
		var $target = $.CurrentNavtab;
		var $checks = $target.find(':checkbox[name=ids]:checked');
        if ($checks.length == 0) {
        	$target.alertmsg("warn", "请选择要更新角色的用户信息！");
            return false;
        }
        var userIds = "";
        if ($checks.length != 0) {
            $checks.each(function(i,v) {
            	userIds += $(this).val() + ",";
            });
            userIds = userIds.substring(0,userIds.length - 1);
        }
        $target.dialog({id: generateMixed(15), type:"POST", mask:true, url:"${server}/admin/update_role_view",data:{userIds:userIds} , title:'更新角色',width:"550",height:"350"});
	}
	
	function update_orders_source(){
		var $target = $.CurrentNavtab;
		var $checks = $target.find(':checkbox[name=ids]:checked');
        if ($checks.length == 0) {
        	$target.alertmsg("warn", "请选择要更新来源的用户信息！");
            return false;
        }
        var userIds = "";
        if ($checks.length != 0) {
            $checks.each(function(i,v) {
            	userIds += $(this).val() + ",";
            });
            userIds = userIds.substring(0,userIds.length - 1);
        }
        $target.dialog({id: generateMixed(15), type:"POST", mask:true, url:"${server}/admin/update_orders_source_view",data:{userIds:userIds} , title:'更新角色',width:"550",height:"350"});
	}
</script>
<div class="bjui-pageHeader">
	<form method="post" id="pagerForm" action="${server}/admin" data-toggle="ajaxsearch" >
		<input type="hidden" name="query" value="true">
		<ul class="bjui-searchBar">
			<li>
				<label class="trtitle01">账号：</label>
				<input type="text" size="15" name="sys_User.loginname" class="form-control" value=""/>
			</li>
			<li>
				<label class="trtitle01">状态：</label>
	            <select name="sys_User.active" data-toggle="selectpicker">
	                <option value="">全部</option>
	                <option value="1">可用</option>
	                <option value="0">不可用</option>
	            </select>
			</li>
			<li>
				<label class="trtitle01">姓名：</label>
				<input type="text" size="15" name="sys_User.username" class="form-control" value=""/>
			</li>
			<li>
				<label class="trtitle01">手机：</label>
				<input type="text" size="15" name="sys_User.mobile" class="form-control" value=""/>
			</li>
			<li>
				<label>邮箱：</label>
	            <input type="text" value="" size="15" name="sys_User.email" class="form-control" />
			</li>
			<!-- <li>
				<a href="javascript:;" class="showMoreSearch" data-toggle="moresearch" data-name="custom" title="更多选项"><i class="fa fa-angle-double-down"></i></a>
			</li> -->
			<li>
			 	<button type="submit" class="btn-default" data-icon="search">查询</button>
			</li>
			<!-- <li>
             	<a class="btn btn-orange" href="javascript:;" data-toggle="reloadsearch" data-clear-query="true" data-icon="undo">清空查询</a>
            </li> -->
		</ul>
		<!-- <div class="bjui-moreSearch">
	            <label>&nbsp;&nbsp;&nbsp;座机：</label>
	            <input type="text" value="" size="15" name="phone" class="form-control" />
	     </div> -->
	</form>
</div>	

<div class="bjui-pageContent">
    <div class="bjui-headBar">
        <ul>
			<li class="left"><a href="${server}/jsp/admin/update.jsp" class="btn btn-default btn-sm" data-icon="save" data-id="control-user-add_view" data-toggle="navtab" data-title="添加管理员" >添加管理员</a></li>
			<li class="left"><a href="${server}/admin/del" class="btn btn-default btn-sm" data-icon="trash-o" data-toggle="doajaxchecked" data-type="post" data-confirm-msg="确定要删除选中项吗？" data-idname="ids" data-group="ids">删除管理员</a></li>
			<li class="left"><a href="${server}/admin/resetPwd" class="btn btn-default btn-sm" data-icon="reply" data-toggle="doajaxchecked" data-type="post" data-confirm-msg="确认重置密码为123456?" data-idname="ids" data-group="ids">重置密码</a></li>
			<li class="left"><a href="${server}/admin/updateState" class="btn btn-default btn-sm" data-icon="reply" data-toggle="doajaxchecked" data-type="post" data-confirm-msg="你确定要更新状态吗?" data-idname="ids" data-group="ids">更新状态</a></li>
     		<li class="left"><button type="button" onclick="update_role()" data-icon="shield"  class="btn btn-default btn-sm">更新角色</button></li>
     		<li class="left"><button type="button" onclick="update_orders_source()" data-icon="shield"  class="btn btn-default btn-sm">更新广告来源</button></li>
       </ul>
    </div>
</div>

<div class="pageContent bjui-resizeGrid" style="top: 29px; bottom: 28px;">
	<table data-toggle="tablefixed" data-layout-h="0" data-nowrap="true">
		<thead>
			<tr align="center">
				<th width="35" style="text-align: center;"><input type="checkbox" class="checkboxCtrl" data-group="ids" data-toggle="icheck"/></th>
				<th>账号</th>
				<th>角色</th>
				<th width="80">来源</th>
				<th>状态</th>
				<th>姓名</th>
				<th>性别</th>
				<th>手机</th>
				<th>座机</th>
				<th>邮箱</th>
				<th>创建人</th>
				<th data-order-field="date_created" class="orderby">创建日期</th>
				<th data-order-field="date_last_login" class="orderby">最后登录日期</th>
				<th>登录次数</th>
				<th style="width:120px;">操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.result}" var="user">
				<tr>
					<td  width="35" style="text-align: center;"><input type="checkbox" name="ids" data-toggle="icheck" value="${user.id}" ></td>
					<td>${user.loginname}</td>
					<td>${user.roles}</td>
					<td title="${user.sources }">${user.sources}</td>
					<td>
						<c:if test="${user.active == 0}">不可用</c:if>
						<c:if test="${user.active == 1}">可用</c:if>
					</td>
					<td>${user.username}</td>
					<td>
						<c:if test="${user.sex == 0}">女</c:if>
						<c:if test="${user.sex == 1}">男</c:if>
					</td>
					<td>${user.mobile}</td>
					<td>${user.phone}</td>
					<td>${user.email}</td>
					<td>${user.createName}</td>
					<td><fmt:formatDate value="${user.date_created}" pattern="yyyy-MM-dd"/></td>
					<td><fmt:formatDate value="${user.date_last_login}" pattern="yyyy-MM-dd"/></td>
					<td>${user.logincount}</td>
					<td>
						<a href="${server}/admin/detail?id=${user.id}" class="btn btn-green" data-id="${user.id}" data-toggle="navtab" data-icon="edit" data-title="编辑-${user.username}" data-reload-warn="本页已有打开的内容，确定将刷新本页内容，是否继续？">编辑</a>
						<a href="${server}/admin/del?ids=${user.id}" class="btn btn-red" data-toggle="doajax" data-type="post" data-confirm-msg="确定要删除该数据吗？">删除</a>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<%@include file="../page.jsp" %>